﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Plat.WfProcess.Common;

namespace Plat.WfProcess.Business
{
    /// <summary>
    /// 活动节点属性定义
    /// </summary>
    public class ActivityEntity
    {
        public string ActivityGUID
        {
            get;
            set;
        }

        public string ProcessGUID
        {
            get;
            set;
        }

        public NodeTypeEnum NodeType
        {
            get;
            set;
        }

        internal bool IsStartNode
        {
            get
            {
                return NodeType == NodeTypeEnum.StartNode;
            }
        }

        internal bool IsEndNode
        {
            get
            {
                return NodeType == NodeTypeEnum.EndNode;
            }
        }

        internal bool IsAutomanticWorkItem
        {
            get
            {
                if ((TaskImplementDetail != null)
                    && ((TaskImplementDetail.ImplementationType | ImplementationTypeEnum.Automantic)
                    == ImplementationTypeEnum.Automantic))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        internal bool IsWorkItemNode
        {
            get
            {
                if ((NodeType | NodeTypeEnum.WorkItemNode) == NodeTypeEnum.WorkItemNode)
                    return true;
                else
                    return false;
            }
        }

        public GatewaySplitJoinTypeEnum GatewaySplitJoinType
        {
            get;
            set;
        }

        public GatewayDirectionEnum GatewayDirectionType
        {
            get;
            set;
        }

        public string ActivityName
        {
            get;
            set;
        }

        public string Description
        {
            get;
            set;
        }

        internal byte RecordStatusInvalid
        {
            get;
            set;
        }

        public TaskImplementDetail TaskImplementDetail
        {
            get;
            set;
        }

        public IList<string> Roles
        {
            get
            {
                ActivityManager am = new ActivityManager(ProcessGUID);
                return am.GetActivityRoles(ActivityGUID);
            }
        }

        public IList<string> DataItemsRequired
        {
            get
            {
                ActivityManager am = new ActivityManager(ProcessGUID);
                return am.GetActivityDataItemsRequired(ActivityGUID);
            }
        }
    }
}
